﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class ybqy_print_fengmian : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();
        SqlConnection sqlcon1 = new SqlConnection();
        sqlcon1.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon1.Open();

        SqlCommand sqlcmd = new SqlCommand("select * from a01101 where ShenBaoNianDu='" + Session["ShenBaoNianDu"] + "' and qiyeid=" + Session["qiyeid"], sqlcon);
        SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);

        if (reader.Read())
        {

            FACT_ADDRESS.Text = reader["FACT_ADDRESS"].ToString(); 
            MASTER_DEP.Text = reader["MASTER_DEP"].ToString();
            WORK_NUMBER.Text = reader["WORK_NUMBER"].ToString();
            ENV_PEOPLE.Text = reader["ENV_PEOPLE"].ToString();
            FACT_TEL.Text = reader["FACT_TEL"].ToString();
            FAX.Text = reader["FAX"].ToString();
            E_MAIL.Text = reader["E_MAIL"].ToString();
            POST_ADDRESS.Text = reader["POST_ADDRESS"].ToString();
            water_facility_type.Text = reader["water_facility_type"].ToString();
            if (reader["STARTWORK_TIME"].ToString() != "" && reader["PERMIT_DATE1"].ToString() != null)
            {
STARTWORK_TIME.Text =  DateTime.Parse(reader["STARTWORK_TIME"].ToString()).ToString("yyyy-MM-dd");
            } 

            
            WORKINGDAYOFYEAR.Text = reader["WORKINGDAYOFYEAR"].ToString();
            EMPLOYEEOFYEAR.Text = reader["EMPLOYEEOFYEAR"].ToString();
            BANK_NAME.Text = reader["BANK_NAME"].ToString();
            BANK_NUM.Text = reader["BANK_NUM"].ToString();
            PRODUCTIONOFYEAR.Text = reader["PRODUCTIONOFYEAR"].ToString();
            TAXOFYEAR.Text = reader["TAXOFYEAR"].ToString();
            PRODUCTION_VALUE.Text = reader["PRODUCTION_VALUE"].ToString();
            MERITOFYEAR.Text = reader["MERITOFYEAR"].ToString();
            EQUIPVALUEOFYEAR.Text = reader["EQUIPVALUEOFYEAR"].ToString();
            FACILITY_NUM.Text = reader["FACILITY_NUM"].ToString();
            DISPOSE_ABILITY.Text = reader["DISPOSE_ABILITY"].ToString();
            RUN_MONEY.Text = reader["RUN_MONEY"].ToString();
            BOILER_NUM.Text = reader["BOILER_NUM"].ToString();
            BIOLER_CNT.Text = reader["BIOLER_CNT"].ToString();
            GAS_SUITNUM.Text = reader["GAS_SUITNUM"].ToString();
            SUFLUR_SUITNUM.Text = reader["SUFLUR_SUITNUM"].ToString();
            yc_BIOLER_CNT.Text = reader["yc_BIOLER_CNT"].ToString();
            so2_BIOLER_CNT.Text = reader["so2_BIOLER_CNT"].ToString();
            INDUSTRY_NUM.Text = reader["INDUSTRY_NUM"].ToString();
            INDUGAS_SUITNUM.Text = reader["INDUGAS_SUITNUM"].ToString();
            INDSUFLUR_SUITNUM.Text = reader["INDSUFLUR_SUITNUM"].ToString();
            GASFACILITY_NUM.Text = reader["GASFACILITY_NUM"].ToString();
            GASFACILITY_ABILITY.Text = reader["GASFACILITY_ABILITY"].ToString();
            GASFACILITY_MONEY.Text = reader["GASFACILITY_MONEY"].ToString();
            SUFLURFACILITY_NUM.Text = reader["SUFLURFACILITY_NUM"].ToString();
            SUFLURFACILITY_ABILITY.Text = reader["SUFLURFACILITY_ABILITY"].ToString();
            PERMIT_CODE1.Text = reader["PERMIT_CODE1"].ToString();
            if (reader["PERMIT_DATE1"].ToString()!="" && reader["PERMIT_DATE1"].ToString()!=null )
            {
                PERMIT_DATE1.Text = DateTime.Parse(reader["PERMIT_DATE1"].ToString()).ToString("yyyy-MM-dd");
            } 
            
            PERMIT_CODE2.Text = reader["PERMIT_CODE2"].ToString();
            if (reader["PERMIT_DATE2"].ToString() != "" && reader["PERMIT_DATE1"].ToString() != null)
            {
PERMIT_DATE2.Text = DateTime.Parse(reader["PERMIT_DATE2"].ToString()).ToString("yyyy-MM-dd");
            }
            
            PERMIT_CODE3.Text = reader["PERMIT_CODE3"].ToString();
            if (reader["PERMIT_DATE3"].ToString() != "" && reader["PERMIT_DATE1"].ToString() != null)
            {
PERMIT_DATE3.Text = DateTime.Parse(reader["PERMIT_DATE3"].ToString()).ToString("yyyy-MM-dd");
            }
            
            CHARGEOFYEAR.Text = reader["CHARGEOFYEAR"].ToString();
            AMERCEOFYEAR.Text = reader["AMERCEOFYEAR"].ToString();


            if (reader["XAIS"].ToString() != "")
            {
                Label3.Text = reader["XAIS"].ToString().Substring(0, 3) + "度" + reader["XAIS"].ToString().Substring(3, 2) + "分" + reader["XAIS"].ToString().Substring(5, 2) + "秒";
            }
            else
            {
                Label3.Text = "";
            }
            if (reader["YAIS"].ToString() != "")
            {
                Label4.Text = reader["YAIS"].ToString().Substring(0, 2) + "度" + reader["YAIS"].ToString().Substring(2, 2) + "分" + reader["YAIS"].ToString().Substring(4, 2) + "秒";
            }
            else
            {
                Label4.Text = "";
            }

            string sqlstr = "SELECT * FROM [CODE_FACTSCALE] where code='" + reader["FACT_SCALE"].ToString() + "'";
            SqlCommand sqlcmd1 = new SqlCommand(sqlstr, sqlcon1);
            SqlDataReader reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader1.Read())
            {
                FACT_SCALE.Text = reader1["name"].ToString();
            }
            reader1.Close();
            sqlcon1.Open();
            sqlstr = "SELECT [FACT_TYPEID], [FACT_TYPE] FROM [CODE_FACT_TYPE] where FACT_TYPEID='" + reader["FACT_TYPE"].ToString() + "'";
            sqlcmd1.CommandText=sqlstr;
            reader1= sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader1.Read())
            {
                FACT_TYPE.Text = reader1["FACT_TYPE"].ToString();
            }
            reader1.Close();
            sqlcon1.Open();
            sqlstr = "SELECT [CODE], [NAME] FROM [CODE_HAVINGTYPE] where CODE='" + reader["FACT_HAVINGTYPE"].ToString() + "'";
            sqlcmd1.CommandText = sqlstr;
            reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader1.Read())
            {
                FACT_HAVINGTYPE.Text = reader1["name"].ToString();
            }
            reader1.Close();
            sqlcon1.Open();
            sqlstr = "SELECT [CODE], [NAME] FROM [CODE_FACT_KIND] where CODE='" + reader["FACT_KIND"].ToString() + "'";
            sqlcmd1.CommandText = sqlstr;
            reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader1.Read())
            {
                FACT_KIND.Text = reader1["name"].ToString();
            }
            reader1.Close();
            sqlcon1.Open();
            sqlstr = "SELECT [CODE], [NAME] FROM [CODE_TRADE] where CODE='" + reader["TRADE_CODE"].ToString() + "'";
            sqlcmd1.CommandText = sqlstr;
            reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader1.Read())
            {
                TRADE_CODE.Text = reader1["name"].ToString();
            }
            
            reader1.Close();
            sqlcon1.Open();
            sqlstr = "SELECT [CODE], [NAME] FROM [CODE_PROJECT_NAME] where CODE='" + reader["PROJECT_NAME"].ToString() + "'";
            sqlcmd1.CommandText = sqlstr;
            reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader1.Read())
            {
                PROJECT_NAME.Text = reader1["name"].ToString();
            }
            reader1.Close();
            sqlcon1.Open();
            sqlstr = "SELECT [CODE], [ATTES] FROM [CODE_ATTE] where CODE='" + reader["FOCUS_TYPE"].ToString() + "'";
            sqlcmd1.CommandText = sqlstr;
            reader1 = sqlcmd1.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader1.Read())
            {
                FOCUS_TYPE.Text = reader1["attes"].ToString();
            }
            sqlcon1.Close();
            sqlcon.Close();
        }
    }
}